<!DOCTYPE html>
<html lang="ch-CN">
<head>
    <meta charset="UTF-8">
    <title>for-判断奇偶性</title>
</head>
<style>
    body {
        width: 100%;
        height: 100vh;
        background-color: wheat;
        font-size: 30px;
        text-decoration: none;
        font-family: "华文楷体";
    }
</style>
<body>
</body>
<script>
    let odd_Arr = [], even_Arr = [];
    let odd_result = 0, even_result = 0, j = 0,x=0;
    // 求50之间的奇数和偶数
    for (let i = 1; i <= 50; i++) {
        // 求奇数
        if (i % 2 !== 0) {
            odd_Arr[x] = i;
            x++;
        }
        // 求偶数
        else {
            even_Arr[j] = i;
            j++;
        }
    }
    // 奇数和
    for (let i = 0; i < odd_Arr.length; i++) {
        odd_result += odd_Arr[i]
    }
    // 偶数和
    for (let i = 0; i < even_Arr.length; i++) {
        even_result += even_Arr[i]
    }
    document.write("奇数有：" + odd_Arr + "<br>" + "奇数和为：" + odd_result + "<br>")
    document.write("<br>" + "偶数有：" + even_Arr + "<br>" + "偶数和为：" + even_result)
</script>
</html>